﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Screen.Master" Inherits="System.Web.Mvc.ViewPage<dbPoll_Application.Models.Question>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Question
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">var webURL = false;</script>
<script type="text/javascript" src="../../Scripts/PageControl.js"></script>
    <%= Html.HiddenFor(m => m.questionID) %>
    <div id="questionObjects">
        <% if (Model.type == dbPoll_Application.Models.QuestionType.Alphanumeric)
           { %>
           <div id="webOnly" class="none">web question only</div>
           <script type="text/javascript">
               $('#webOnly').slideDown('slow');
           </script>
        <% } %>
        <% if (Model.countdownTimer.active)
           { %>
        <div id="countdown" class="none">countdown: <%= Model.countdownTimer.countdownAmount %></div>
        <script type="text/javascript">
            $('#countdown').slideDown('slow');
            var countdownAmount = <%= Model.countdownTimer.countdownAmount %>;
            function timer() {
                if (countdownAmount > 0) {
                    countdownAmount--;
                    $('#countdown').text("countdown: " + countdownAmount);
                    setTimeout("timer()", 1000);
                }
            }
            setTimeout("timer()", 1000);
        </script>
        <% } %>
        <% if (Model.responseCounter.active)
           { %>
        <div id="responses" class="none">responses:</div>
        <script type="text/javascript">
            $('#responses').slideDown('slow');
            window.setInterval(function() {
                $.ajax({
                    type: 'POST',
                    url: "/Screen/GetResponseCount",
                    data: { questionID: $('#questionID').val() },
                    success: function(response) {
                        $('#responses').text("responses: " + response);
                    }
                });
            }, 1000);
        </script>
        <% } %>
    </div>
    <div id="contentContainer">
    <input type="hidden" id="pollID" name="pollID" value="<%= ViewData["pollID"] %>" />
        <div id="screenQuestionContainer">
        <div id="questionContainer">
            <div id="questionTitle" style="color:<%= Model.fontColour %>; font-size:<%= Model.fontSize %>px;"><%= Model.question %></div>
            <div class="clear"></div>
            <div id="optionsContainer">
                <% if (Model.GetParentType() == "MCQ")
                   {
                       var question = Model as dbPoll_Application.Models.MultipleChoiceQuestion;
                       var options = question.options; %>
                       <table class="options">  
	                   <% foreach (var option in options)
                       { %>
                            <tr>
                                <% if (option.correctCurrent)
                                   { %>
                                <td class="questionOptionNumber questionOptionFont" style="color:<%= Model.fontColour %>; font-size:<%= Model.fontSize %>px;"><span class="correctOption"><%= option.optionNumber%>.</span></td>
                                <% }
                                   else
                                   { %>
                                <td class="questionOptionNumber questionOptionFont" style="color:<%= Model.fontColour %>; font-size:<%= Model.fontSize %>px;"><%= option.optionNumber%>.</td>
                                   <% } %>
	                            <td class="questionOption questionOptionFont" style="color:<%= Model.fontColour %>; font-size:<%= Model.fontSize %>px;"><%= option.answer %></td>
	                        </tr>
	                   <% } %>
	                   </table>
	            <% } %>
	        </div>
	    </div>
	    </div>
	    <% if (Model.responseGrid.active)
        {
            var participants = ViewData["participants"] as IList<dbPoll_Application.Models.Participant>; %>
            <script type="text/javascript" src="../../Scripts/Screen-KeypadTest.js"></script>
            <div id="responseGrid">
            <% Html.RenderPartial("ResponseGrid", participants); %>
	        </div>
	    <% } %>
	</div>
	            
</asp:Content>
